/* 
 * File:   driver_rtc.h
 * Author: Ich
 *
 * Created on 23.02.2014, 16:03
 *
 * Description:
 * Driver for real time clock module MCP7940N.
 * Communication is with I2C. Clock Rate up to 400kHz.
 */

#ifndef DRIVER_RTC_H
#define	DRIVER_RTC_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <GenericTypeDefs.h>
/*******************************************************************************
 *  public preprocessing definitions
 */
 /*******************************************************************************
 *  public variables
 */

/*******************************************************************************
 *  public functions
 */

/* Initialises RTC module
 *
 * param(in)    interruptFunction   function that will be called on interrupt
 */
void drvRtc_init                (void (*interruptFunction)(void));


/* Set's the time. All data are in BCD.
 * --> hour 13 = 0x13
 * time is always in 24h-mode
 *
 * param(in)    hour    [as BCD]
 * param(in)    min     [as BCD]
 * param(in)    sec     [as BCD]
 *
 * return       success true=ok
 *
 */
BOOL drvRtc_setTime             (UINT8 hour, UINT8 min, UINT8 sec);


/* Set's the date. All data are in BCD.
 * --> month 12 = 0x12
 *
 * param(in)    year    [as BCD]
 * param(in)    month   [as BCD]
 * param(in)    day     [as BCD]
 *
 * return       success true=ok
 *
 */
BOOL drvRtc_setDate             (UINT8 year, UINT8 month, UINT8 day);


/* Get's the time.
 *
 * param(out)   pHour       [as BCD] pointer to hour
 * param(out)   pMin        [as BCD] pointer to min
 * param(out)   pSec        [as BCD] pointer to sec
 *
 * return       success     true = ok
 *
 */
BOOL drvRtc_getTime             (UINT8 *pHour, UINT8 *pMin, UINT8 *pSec);


/* Get's the date.
 *
 * param(out)   pYear    [as BCD] pointer to year
 * param(out)   pMonth   [as BCD] pointer to month
 * param(out)   pDay     [as BCD] pointer to day
 *
 * return       success true=ok
 *
 */
BOOL drvRtc_getDate             (UINT8 *pYear, UINT8 *pMonth, UINT8 *pDay);


/* Switch off all alarms.
 *
 * return       success true=ok
 *
 */
BOOL drvRtc_alarmOff            (void);


/* Set alarm #0 function as minute alarm.
 * Every minute it generates an alarm.
 *
 * return       success true=ok
 *
 */
BOOL drvRtc_setMinuteAlarm      ( void );


/* Clear alarm flag. If an alarm is occured,
 * you have to clear manually alarm flag.
 *
 * return       success true=ok
 *
 */
BOOL drvRtc_clearAlarmFlag      ( void );




#ifdef	__cplusplus
}
#endif

#endif	/* DRIVER_RTC_H */


